package org.nfIt.entity;



import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.URL;
import org.nfIt.anno.State;

import java.time.LocalDateTime;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Article {
    @NotNull(groups = update.class)//必须要传
    private Integer id;//主键ID

    @NotEmpty(groups = {Add.class, update.class})//添加和修改 必须要传,并且不可是空字符串
    @Pattern(regexp = "^\\S{1,10}$")
    private String title;//文章标题

    @NotEmpty(groups = {Add.class, update.class})//添加和修改 必须要传,并且不可是空字符串
    private String content;//文章内容

    @NotEmpty(groups = {Add.class, update.class})//添加和修改 必须要传,并且不可是空字符串
    @URL
    private String coverImg;//封面图像

    @State(groups = {Add.class, update.class})//添加和修改 必须要传,并且不可是空字符串
    private String state;//发布状态 已发布|草稿

    @NotNull
    private Integer categoryId;//文章分类id

    private Integer createUser;//创建人ID
    private LocalDateTime createTime;//创建时间
    private LocalDateTime updateTime;//更新时间

    //@Validated注解中使用添加分组
    public interface Add {

    }

    //更新分组
    public interface update {

    }
}
